package com.jf.docsify;

import com.jf.docsify.config.DocsifyConfig;
import com.jf.docsify.servlet.git.GitIdentityManager;
import com.jfinal.server.undertow.UndertowServer;

import java.io.File;

/**
 * Description: 启动类
 *
 * @author chenwr
 * @version 1.0
 *
 * <pre>
 * 修改记录:
 * 修改后版本           修改人       修改日期         修改内容
 * 2022/7/25.1       chenwr    2022/7/25           Create
 * </pre>
 * @date 2022/7/25
 */
public class DocsifyStart {

    public static void main(String[] args) {
        DocsifyConfig.createDefaultDocFolder();
        UndertowServer.create(DocsifyConfig.class).configWeb(builder -> {
            builder.addServlet("gitServlet", "com.jf.docsify.servlet.GitServlet");
            builder.setServletLoadOnStartup("gitServlet", 1);
            builder.addServletMapping("gitServlet", "/git/*");
            builder.addServletInitParam("gitServlet", "base-path", DocsifyConfig.defaultPath + File.separator + DocsifyConfig.gitDefaultFolderName);
            builder.addServletInitParam("gitServlet", "export-all", "true");
            builder.getDeploymentInfo().setIdentityManager(new GitIdentityManager());
        }).start();
    }

}